using System;

namespace Ayatta.Contract.Domain
{
    [Serializable]
    public abstract class BaseEntity<T> : Validatable<T>
    {
        /// <summary>
        /// 创建者
        /// </summary>
        public string CreatedBy { get; set; }

        /// <summary>
        /// 创建日期时间
        /// </summary>
        public DateTime CreatedOn { get; set; }

        protected BaseEntity()
        {
            const string message = "Id类型只能为long,int,short,string,guid";
            if (typeof(T) != typeof(long) && typeof(T) != typeof(int) && typeof(T) != typeof(short) &&
                typeof(T) != typeof(string) && typeof(T) != typeof(Guid))
            {
                throw new ArgumentException(message);
            }
        }
    }
}